package base;

public class TreeNode {
    public int val;

    public TreeNode left;

    public TreeNode right;

    public TreeNode() {

    }

    public TreeNode(int val) {
        this.val = val;
    }

    public TreeNode(int val, TreeNode left, TreeNode right) {
        this.val = val;
        this.left = left;
        this.right = right;
    }

    public String print() {
        String info = printTree(this);
        return info;
    }

    public String printTree(TreeNode tree) {
        StringBuffer buffer = new StringBuffer();
        if(tree != null) {
            buffer.append(" ").append(tree.val);
            buffer.append(printTree(tree.left));
            buffer.append(printTree(tree.right));
        }

        return buffer.toString();
    }


}
